﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="main.aspx.cs" Inherits="jnlamp.Web.mobile.main" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>杀虫灯系统平台</title>
    <link rel="stylesheet" type="text/css" href="easyui/themes/metro/easyui.css" />
    <link rel="stylesheet" type="text/css" href="easyui/themes/mobile.css" />
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css" />
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.mobile.js"></script>
    <script src="easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="../Script/datetime.js"></script>
    <script src="js/mobile.js"></script>
    <script type="text/javascript">
        $(function () {
            InitGird();
            initMenu();
        });
        function InitGird() {
            $('#tt').datagrid({
                title: '基地列表', //表格标题
                url: '../baseinfo/GetBase.ashx', //请求数据的页面
                sortName: 'basedate', //排序字段
                idField: 'bid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: true, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true,
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: false,
                method: 'post',
                columns: [[
                    { title: '基地名称', field: 'basename', width: 100 },
                    {
                        title: '创建日期', field: 'basedate', sortable: true, width: 90, formatter: function (value, row, index) {
                            if (value != "") {

                                if (value.indexOf("-") != -1)
                                    value = value.replace(/-/g, "/");
                                return new Date(value).pattern("yyyy年M月d日");
                            }
                        }
                    },
                    {
                        title: '灯浏览', field: 'a', width: 60, formatter: function (value, row, index) {
                            return '<a href="list.aspx?bid=' + row.bid + '">灯浏览</a>';

                        }
                    },
                    { title: '项目', field: 'proname', width: 80 },
                    { title: '地址', field: 'address', width: 150 },

                    { title: '备注', field: 'basemark', width: 150 }
                ]],                
                onLoadSuccess: function (data) {
                    //根据所有基地加载网关与灯
                    var baseids = "";
                    $.each(data.rows, function (k, v) {
                        if (baseids.length > 0)
                            baseids = baseids + "," + v["bid"];
                        else {
                            baseids = v["bid"];
                        }
                    });                    
                    showlamp(baseids);

                },                
                queryParams: { "action": "querymy"},
                pagination: true, //是否开启分页
                pageList: [10, 20, 30, 40, 50],
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });            
        }
        function showlamp(baseids) {
            $.ajax({
                type: "post",
                dataType: "json",
                url: "/lampinfo/GetScd.ashx?action=querybc&bid=" + baseids,
                success: function aa(data) {
                    var info = "";
                    info = "共有灯" + data.total + "台。";
                    //var sl = [];
                    //var sh = [];
                    //var state = "";
                    //var mname = "";
                    //var slnum = 0;
                    //var shnum = 0;
                    //$.each(data.rows, function (k, v) {
                    //    state = v["lampstatus"];
                    //    if (state == '3' || state == '') {
                    //        slnum = slnum + 1;
                    //        mname = v["mname"];
                    //        if (sl[mname]) {
                    //            sl[mname] = sl[mname] + 1;
                    //        }
                    //        else {
                    //            sl[mname] = 1;
                    //        }
                    //    }
                    //    else if (state == '2') {
                    //        shnum = shnum + 1;
                    //        mname = v["mname"];
                    //        if (sh[mname]) {
                    //            sh[mname] = sh[mname] + 1;
                    //        }
                    //        else {
                    //            sh[mname] = 1;
                    //        }
                    //    }

                    //});
                    //var outputsl = "";
                    //for (var key in sl) {
                    //    if (sl.hasOwnProperty(key))
                    //        if (outputsl == "") {
                    //            outputsl = key + '(' + sl[key] + ')';
                    //        }
                    //        else {
                    //            outputsl += "、" + key + '(' + sl[key] + ')';
                    //        }
                    //}
                    //var outputsh = "";
                    //for (var key in sh) {
                    //    if (sh.hasOwnProperty(key))
                    //        if (outputsh == "") {
                    //            outputsh = key + '(' + sh[key] + ')';
                    //        }
                    //        else {
                    //            outputsh += "、" + key + '(' + sh[key] + ')';
                    //        }
                    //}
                    //if (slnum > 0)
                    //    info = info + "失联" + slnum + "台，失联详情：" + outputsl + "。";
                    //if (shnum > 0)
                    //    info = info + "损坏" + shnum + "台,损坏详情：" + outputsh + "。";
                    $('#myinfo').html(info);
                }
            });
        }
    </script>
</head>
<body>
    <div class="easyui-navpanel">

        <table id="tt" data-options="header:'#hh',singleSelect:true,border:false,fit:true,fitColumns:true,scrollbarSize:0">
            
        </table>
        <div id="hh">
            <div class="m-toolbar">
                <div class="m-title"><span id="myinfo" style="line-height:20px;">灯信息</span></div>
            </div>
        </div>
        <footer>
            <div class="m-buttongroup m-buttongroup-justified" style="width: 100%">
                <a  id="mymain" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-large-chart',size:'large',iconAlign:'top',plain:true">查看设备</a>
                <a id="equqtop" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-large-clipart',size:'large',iconAlign:'top',plain:true">群体操作</a>
                <a  href="/mobile/equsdsz.aspx" class="easyui-linkbutton" data-options="iconCls:'icon-large-shapes',size:'large',iconAlign:'top',plain:true">单灯/时段设置</a>
                <a id="myexist" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-large-smartart',size:'large',iconAlign:'top',plain:true">退出</a>
            </div>
        </footer>

    </div>

</body>
</html>
